/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fbv.tcc.modelo;

import fbv.tcc.utils.Utils;
import java.util.ArrayList;

/**
 *
 * @author Casa
 */
public class ModeloFisico {

    private double anguloSolar;
    private int diaJuliano;
    private double massa;
    private double altitude;
    private double cteSolar;
    private double anguloZenital;

    public double getAnguloZenital() {
        return anguloZenital;
    }

    public ModeloFisico() {
      
    }

    public void setAnguloZenital(double anguloZenital) {
        this.anguloZenital = anguloZenital;
    }

    public double getCteSolar() {
        return cteSolar;
    }

    public void setCteSolar(double cteSolar) {
        this.cteSolar = cteSolar;
    }

    public double getAnguloSolar() {
        return anguloSolar;
    }

    public void setAnguloSolar(double anguloSolar) {
        this.anguloSolar = anguloSolar;
    }

    public int getDiaJuliano() {
        return diaJuliano;
    }

    public void setDiaJuliano(int diaJuliano) {
        this.diaJuliano = diaJuliano;
    }

    public double getMassa() {
        return massa;
    }

    public void setMassa(double massa) {
        this.massa = massa;
    }

    public double getAltitude() {
        return altitude;
    }

    public void setAltitude(double altitude) {
        this.altitude = altitude;
    }

    {
        //calula Epilson
    /*
         private double calculaExcentricidadeOrbitaTerrestre() {

         double aux = 0.03344 * Math.cos((2 * Math.PI * this.getDiaJuliano()) / 365.25);

         return (1 + aux);
         }

         private double calculaProfundidadeOtica() {

         double saida = 0;

         if (this.getMassa() <= 20) {
         saida = (1 / (6.62960 + (1.75130 * this.getMassa()) - (0.12020 * Math.pow(this.getMassa(), 2)) + (0.00650 * Math.pow(this.getMassa(), 3)) - (0.00013 * Math.pow(this.getMassa(), 4))));
         } else {
         saida = (1 / (10.4 + (0.718 * this.getMassa())));
         }
         return saida;
         }

         private double calculaDeltaElevacaoAnguloSolar() {

         double saida = 0.061359 * ((0.1594 + 1.1203 * this.getAnguloSolar() + 0.06565 * Math.pow(this.getAnguloSolar(), 2)) / (1 + 28.9344 * this.getAnguloSolar() + 277.3971 * Math.pow(this.getAnguloSolar(), 2)));

         return saida;
         }

         private double calculaAnguloElevacaoSolarTrue() {

         return (this.getAnguloSolar() + calculaDeltaElevacaoAnguloSolar());
         }

         private double calculaMassaAr() {

         double aux = (1 - (this.getAltitude() / Math.pow(10, 4)));
         double aux2 = (57.29578 * calculaAnguloElevacaoSolarTrue() + 6.07995);

         double massa = aux / Math.sin(calculaAnguloElevacaoSolarTrue() + 0.50572 * (Math.pow(aux2, -1.6364)));

         return massa;
         }*/
    }

    public ArrayList<Double> calculaRadiacaoET(int diaJuliano, double lon, double lat, ArrayList<Double> horas) {
        
        //Iet = IoEcosS
        //E = 1 + 0.3344cos(2pij/365.25)
        //S = angulo zenital
        
       ArrayList<Double> Iet = new ArrayList<Double>();

        for (int t = 0; t < horas.size(); t++) {
            double Lof = 45;//Longitude Oficial

            //gerador de hora    
            double tof = horas.get(t);

            //double tof=12; //hora oficial

            double rad = (2 * Math.PI) / 360;
            double B = ((2 * Math.PI * (diaJuliano - 1)) / 365);
            double Emin = 229.2 * (0.000075 + 0.001868 * Math.cos(B) - 0.032077 * Math.sin(B) - 0.014615 * Math.cos(2 * B) - 0.04089 * Math.sin(2 * B));

            double ts = tof + 4 * (Lof - lon) + Emin - 1; //inserir delocamento

            double omega = 15 * (12 - ts);

            double delta = 23.45 * Math.sin(((2 * Math.PI * (diaJuliano - 81)) / 365));

            double E = 1 + 0.3344 * Math.cos(((2 * Math.PI * (diaJuliano)) / 365.25)); //Excentricidade da orbita terrestre

            double cosZenit = Math.sin(rad * delta) * Math.sin(rad * lat) + Math.cos(rad * delta) * Math.cos(rad * lat) * Math.cos(rad * omega);


           double aux = 1365 * E * cosZenit;
           if(aux>0){
            Iet.add(aux);
           }
        }
        return Iet;
    }
}
